

import { characterStateClient, controllerClient, move2DClient, SkillClient } from "./clientLib";
import { SkillEnum } from "shared/enums/SkillEnum";
import rMath from "shared/component/common/rMath";
import Log4R from "shared/component/log/Log4R";
const loginfo = Log4R.getLog('info');
/** 控制服务 */


/* 遥感方向改变 */
controllerClient.onStickChange(vector => {
    // loginfo?.info('onStickChange', vector)
    const character = game.GetService('Players').LocalPlayer.Character as Ctn.character.HumanModel
    const vect2 = new Vector2(vector.X, vector.Z);
    /**
     * stick角度
     */
    const degree = math.deg(vect2.Angle(rMath.vectors.x0,true))
    loginfo?.info('degree', degree)
    move2DClient.movePlayer(vector, degree)
    characterStateClient.setControlDegree(character, degree)
})
/* 动作按钮改变 */
controllerClient.onActButtonChange(actStates => {
    const character = game.GetService('Players').LocalPlayer.Character as Ctn.character.HumanModel
    if (actStates.act === 'SkillA' && actStates.press)
        SkillClient.skill({
            skillId: SkillEnum.swordS1,
            character: character,
            currentFrame: 0,
            skillConfig: undefined
        })
    if (actStates.act === 'dodge' && actStates.press)
        SkillClient.skill({
            skillId: SkillEnum.dodge,
            character: character,
            currentFrame: 0,
            skillConfig: undefined
        })
    move2DClient.actPlayer({
        act: actStates.act,
        enable: actStates.press,
    })
    characterStateClient.act({
        act: actStates.act,
        enable: actStates.press,
    }, character)
})